package com.exm.collectcodenew.kafka.producer.customSerializer;

import com.alibaba.fastjson.JSON;
import org.apache.kafka.common.serialization.Deserializer;

import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;
public class UserDeserializer implements Deserializer {
    @Override
    public void configure(Map configs, boolean isKey) {
    }
    @Override
    public Object deserialize(String topic, byte[] data) {
        if (Objects.isNull(data)) {
            return null;
        }
        String userStr = new String(data, StandardCharsets.UTF_8);
        return JSON.parseObject(userStr, User.class);
    }
    @Override
    public void close() {
    }
}
